#include <stdio.h>
#include <stdlib.h>

void procesarNodo(int com, int N, int* result, unsigned long long pot) {
	int valores[N];
	for (int i = 1; i < N; i++) {
		valores[i] = com % N;
		com = com / N;
	};
	valores[0] = com;

	bool cumple = true;
	for (int i = 0; (i < N) && (cumple); i++) {
		for (int j = 0; (j < N) && (cumple); j++) {
			if (i != j) {
				if ((valores[i] == valores[j])
						|| (abs(i - j) == abs(valores[i] - valores[j]))) {
					cumple = false;
				}
			}
		}
	}
	if (cumple) {
		*result = *result + 1;
	}
}
;

unsigned long long cantidadComb(int N) {
	unsigned long long aux = 1;
	for (int i = 0; i < N; i++) {
		aux = N * aux;
	}
	return aux;
}
;

int main(int argc, char *argv[]) {

	for (int N = 2; N < 11; N++) {
		int result = 0;
		unsigned long long  cantidadCombinaciones= cantidadComb(N);

		for (unsigned long long i = 0; i < cantidadCombinaciones; i++) {
			procesarNodo(i, N, &result, cantidadCombinaciones);
		}
		printf("N = %d Cantidad: %d\n", N, result);
	}
	return 0;
}
;
